package Invaders;

import java.awt.Dimension;
import java.awt.Image;
import javax.swing.ImageIcon;

public class InvaderTeleporter extends Invader{

	private int contTeleporter;
	private Image iconTeleporting;
	private Image iconNormal;
	
	public InvaderTeleporter(Dimension a) {
		super(a);
		life = 3;
		score = 10;
		contTeleporter = 0;
		area = a;
	    iconNormal = new ImageIcon(getClass().getResource("/Sprites/teleporter.gif")).getImage();
	    iconTeleporting = new ImageIcon(getClass().getResource("/Sprites/teleporting.gif")).getImage();
	    icon = iconNormal;
	    dano = 1;
	}
	
	public void move() {
		if(contTeleporter >= 250) {
			icon = iconTeleporting;
		}
		else {
			icon = iconNormal;
		}
		contTeleporter++;
		if(contTeleporter < 300) {
			x += dx;
			y += dy;
			if (x < 0) { 
				 dx = -dx; 
				 x += dx; 
			} 
			if (y < 0) { 
				dy = -dy; 
				 y += dy; 
			} 
			if (x > area.width-iw) { 
			 	x = -dx; 
			 	x += dx; 
			} 
			if (y > area.height-ih) { 
				dy = -dy; 
				y += dy; 
			}
		}
		else {
			contTeleporter = 0;
			x = (int)(iw/2+Math.random()*(area.width-iw));
		    y = (int)(ih/2+Math.random()*(area.height-300-ih));
		}
	}
}
